package com.shenzhen.horselive.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.flqy.baselibrary.utils.L;
import com.shenzhen.horselive.R;
import com.shenzhen.horselive.adapter.JuBaoAdapter;
import com.shenzhen.horselive.databinding.DialogJubaoBinding;
import com.shizhefei.recyclerview.BaseHFAdapter;

import java.util.List;

public class JuBaoDialog extends Dialog {
    public JuBaoDialog(@NonNull Context context) {
        super(context, R.style.CommonDialog);
        binding =  DialogJubaoBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        initViews();
    }

    public JuBaoDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    DialogJubaoBinding  binding;


    JuBaoAdapter  adapter;
    private void initViews() {
        binding.recyclerview.setLayoutManager(new LinearLayoutManager(getContext()));
        adapter =  new JuBaoAdapter(R.layout.item_dialog_jubao);
        binding.recyclerview.setAdapter(adapter);
        binding.btGo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
    public  void  setList(List<String>  list)
    {
        adapter.setNewInstance(list);
    }

    //条目点击
    public void   setOnItemClick(OnItemClickListener onItemClick)
    {
        adapter.setOnItemClickListener(onItemClick);
    }


    @Override
    public void show() {
        super.show();
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.width= ViewGroup.LayoutParams.MATCH_PARENT;
        layoutParams.height= ViewGroup.LayoutParams.WRAP_CONTENT;
        layoutParams.gravity = Gravity.BOTTOM;
        getWindow().setAttributes(layoutParams);
    }
}
